﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace Gama.Service
{
    public static class SqlService
    {
        #region "Support Connectiong Database" 
        
        public static IDataReader ExecuteNonQuery(string storeName, params object[] param)
        {
            return (IDataReader)SqlHelper.ExecuteReader(Ultilities.ConnectionString, storeName, param);
        }
        public static IDataReader ExecuteNonQuery(string query)
        {
            return (IDataReader)SqlHelper.ExecuteReader(Ultilities.ConnectionString,CommandType.Text, query);
        }

        public static bool ExecuteNonQueryWithoutResult(string storeName, params object[] param)
        {
            return SqlHelper.ExecuteNonQuery( Ultilities.ConnectionString, storeName, param) > 0;
        }
        public static bool ExecuteNonQueryWithoutResult(string query)
        {
            return SqlHelper.ExecuteNonQuery(Ultilities.ConnectionString, CommandType.Text,query) > 0;
        }

        public static object ExecuteScalar(string storeName, params object[] param)
        {
            return SqlHelper.ExecuteScalar(Ultilities.ConnectionString, storeName, param);
        }
        public static object  ExecuteScalar(string query)
        {         
            return SqlHelper.ExecuteScalar(Ultilities.ConnectionString, CommandType.Text, query);           
        }
        #endregion 
    }
}
